package com.cc.crm.timer.thread;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Comparator;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Description: 定时调用线程池
 * @Auther: 新梦想*陈超
 * @Date: 2020-12-30 15:35
 */
public class ScheduledExecutor {
    public static void main(String[] args) {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(10);
        // 参数：1、具体执行的任务   2、首次执行的延时时间
        //      3、任务执行间隔     4、间隔时间单位
        service.scheduleAtFixedRate(() ->
                        System.out.println("执行任务A:" + LocalDateTime.now()),
                0, 3, TimeUnit.SECONDS);
        service.schedule(() -> System.out.println("=====开始启动===="), 5, TimeUnit.SECONDS);

        Integer[] arr = {1, 2, 2};
        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return 0;
            }
        });
    }
}
